package demo9;

import java.util.*;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder("");

        while(sc.hasNext()){
            int n = sc.nextInt();
            int[] arr = new int[n];
            int[] arr1 = new int[n];
            int[] arr2 = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
                if(i%2==0){
                    arr1[i] = arr[i];
                    arr2[i] = -arr[i];
                }else{
                    arr1[i] = -arr[i];
                    arr2[i] = arr[i];
                }
            }
            int res = Math.max(maxSubArray(arr1),maxSubArray(arr2));
            System.out.println(res);
        }
    }

    public static int maxSubArray(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n+1];
        int max = Integer.MIN_VALUE;
        for (int i = 1; i <= n ; i++) {
            if(dp[i-1]<0){
                dp[i] = nums[i-1];
            }else{
                dp[i] = nums[i-1] + dp[i-1];
            }
            max = Math.max(max,dp[i]);
        }
        return max;
    }
}
